home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_TraceVar Tcl Command Language Library Tcl_TraceVar
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Tcl_TraceVar, Tcl_UnTraceVar, Tcl_VarTraceInfo - monitor
- accesses to a variable
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ttccll..hh>>
-
- int
- TTccll__TTrraacceeVVaarr((_i_n_t_e_r_p, _v_a_r_N_a_m_e, _g_l_o_b_a_l, _f_l_a_g_s, _p_r_o_c, _c_l_i_e_n_t_D_a_t_a))
-
- TTccll__UUnnTTrraacceeVVaarr((_i_n_t_e_r_p, _v_a_r_N_a_m_e, _g_l_o_b_a_l))
-
- int
- TTccll__VVaarrTTrraacceeIInnffoo((_i_n_t_e_r_p, _v_a_r_N_a_m_e, _g_l_o_b_a_l, _p_r_o_c_P_t_r, _c_l_i_e_n_t_D_a_t_a_P_t_r))
-
- AARRGGUUMMEENNTTSS
- Tcl_Interp *_i_n_t_e_r_p (in) Interpreter contain-
- ing variable.
-
- char *_v_a_r_N_a_m_e (in) Name of variable.
-
- int _g_l_o_b_a_l (in) If non-zero, then
- treat _v_a_r_N_a_m_e as
- global variable,
- ignoring any active
- Tcl procedure
- frames. If zero,
- look up variable in
- current procedure's
- context.
-
- int _f_l_a_g_s (in) OR-ed combination of
- the values
- TCL_TRACE_READS,
- TCL_TRACE_WRITES,
- and
- TCL_TRACE_DELETES.
- Indicates which
- operations are to be
- traced.
-
- char *((*_p_r_o_c)()) (in) Procedure to invoke
- whenever one of the
- traced operations
- occurs.
-
- ClientData _c_l_i_e_n_t_D_a_t_a (in) Arbitrary one-word
- value to pass to
- _p_r_o_c.
-
-
-
-
- Sprite v.1.0 Printed: July 31, 1990 1
-
-
-
-
-
-
- Tcl_TraceVar Tcl Command Language Library Tcl_TraceVar
-
-
-
- char *((**_p_r_o_c_P_t_r)()) (out) Pointer to word in
- which to store
- address of current
- trace procedure for
- _v_a_r_N_a_m_e, if any.
-
- ClientData *_c_l_i_e_n_t_D_a_t_a_P_t_r (out) Pointer to word in
- which to store
- ClientData for
- current trace for
- _v_a_r_N_a_m_e, if any.
-
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- TTccll__TTrraacceeVVaarr allows an arbitrary C procedure to be inter-
- posed in the access path to a variable, so that all reads or
- writes to that variable are mediated by the procedure. The
- _f_l_a_g_s argument to TTccll__TTrraacceeVVaarr indicates which operations
- are to cause _p_r_o_c to be invoked; it consists of an OR-ed
- combination of any of the following values:
-
- TTCCLL__TTRRAACCEE__RREEAADDSS
- Invoke _p_r_o_c whenever an attempt is made to read the
- variable.
-
- TTCCLL__TTRRAACCEE__WWRRIITTEESS
- Invoke _p_r_o_c whenever an attempt is made to modify the
- variable.
-
- TTCCLL__TTRRAACCEE__DDEELLEETTEESS
- Invoke _p_r_o_c whenever the trace on the variable is
- removed. This can happen either because TTccll__UUnnTTrraacceeVVaarr
- is called, or because the variable was deleted (e.g. it
- is a local variable and the procedure is returning).
-
- If the trace is created successfully then TTccll__TTrraacceeVVaarr
- returns TCL_OK. If an error occurred (e.g. there is already
- a trace set on the variable) then TCL_ERROR is returned and
- an error message will be left in _i_n_t_e_r_p->_r_e_s_u_l_t.
-
- Whenever one of the specified operations occurs, _p_r_o_c will
- be invoked. It should have the following structure:
- char *
- _p_r_o_c(_c_l_i_e_n_t_D_a_t_a, _i_n_t_e_r_p, _v_a_r_N_a_m_e, _g_l_o_b_a_l, _f_l_a_g_s, _o_l_d_V_a_l_u_e, _n_e_w_V_a_l_u_e)
- ClientData _c_l_i_e_n_t_D_a_t_a;
- Tcl_Interp *_i_n_t_e_r_p;
- char *_v_a_r_N_a_m_e;
- int _g_l_o_b_a_l;
- int _f_l_a_g_s;
- char *_o_l_d_V_a_l_u_e;
- char *_n_e_w_V_a_l_u_e;
- {
-
-
-
- Sprite v.1.0 Printed: July 31, 1990 2
-
-
-
-
-
-
- Tcl_TraceVar Tcl Command Language Library Tcl_TraceVar
-
-
-
- }
- The _c_l_i_e_n_t_D_a_t_a, _i_n_t_e_r_p, and _v_a_r_N_a_m_e parameters will have the
- same values as those passed to TTccll__TTrraacceeVVaarr when the trace
- was created. _C_l_i_e_n_t_D_a_t_a typically points to an
- application-specific data structure that describes what to
- do when _p_r_o_c is invoked. _G_l_o_b_a_l indicates whether or not
- the variable is a global one; it may be needed by _p_r_o_c if
- _p_r_o_c calls TTccll__GGeettVVaarr or TTccll__SSeettVVaarr. The _f_l_a_g_s parameter
- will have one of the bits TCL_TRACE_READS, TCL_TRACE_WRITES,
- or TCL_TRACE_DELETES set; this indicates which operation is
- being performed on the variable. In addition, the bit
- corresponding to TCL_VARIABLE_UNDEFINED will be set in _f_l_a_g_s
- if the variable has never been assigned a value. _O_l_d_V_a_l_u_e
- gives the variable's current value; it points to an empty
- string if TCL_VARIABLE_UNDEFINED is set. _N_e_w_V_a_l_u_e gives the
- new value being stored in the variable, if this is a write
- operation; otherwise it points to an empty string.
-
- For read tracing, the return value from _p_r_o_c is the value
- that will be returned to the reader; if _p_r_o_c returns NULL,
- this is a signal to the reader that the variable is unde-
- fined. _P_r_o_c may return _o_l_d_V_a_l_u_e or something completely
- different, at its discretion. For write tracing, the return
- value from _p_r_o_c is ignored. However, it is up to _p_r_o_c to
- change the variable's value, if it wishes to allow the write
- to proceed. To do this, _p_r_o_c should call TTccll__SSeettVVaarr. For
- delete tracing, the return value from _p_r_o_c is also ignored;
- the primary purpose of this trace call is to allow _p_r_o_c to
- free up its data structures associated with the trace.
-
- Tracing is temporarily disabled on the variable while _p_r_o_c
- is executing. This means that _p_r_o_c may call TTccll__GGeettVVaarr and
- TTccll__SSeettVVaarr without fear of infinite recursion on itself: the
- calls will operate directly on the variable, as if there
- were no tracing. Once _p_r_o_c returns the trace is re-enabled.
-
- TTccll__UUnnSSeettTTrraaccee may be used to remove a trace from the vari-
- able given by _i_n_t_e_r_p, _v_a_r_N_a_m_e, and _g_l_o_b_a_l. If the current
- trace includes TCL_TRACE_DELETES, then the trace procedure
- will be invoked one last time as part of the TTccll__UUnnSSeettTTrraaccee
- call. If there is currently no trace on the selected vari-
- able then TTccll__UUnnSSeettTTrraaccee has no effect.
-
- TTccll__VVaarrTTrraacceeIInnffoo is used to find out about the current trace
- on a variable, if any. The arguments _p_r_o_c_P_t_r and _c_l_i_e_n_t_D_a_-
- _t_a_P_t_r point to variables that TTccll__VVaarrTTrraacceeIInnffoo fills in with
- the _p_r_o_c and _c_l_i_e_n_t_D_a_t_a arguments (respectively) from the
- call that created the current trace. The return value is
- the _f_l_a_g_s argument from the call that created the current
- trace. If there is no trace on the indicated variable, or
- if the variable doesn't exist, then 0 is returned and
- *_p_r_o_c_P_t_r and *_c_l_i_e_n_t_D_a_t_a_P_t_r are both set to NULL.
-
-
-
- Sprite v.1.0 Printed: July 31, 1990 3
-
-
-
-
-
-
- Tcl_TraceVar Tcl Command Language Library Tcl_TraceVar
-
-
-
- KKEEYYWWOORRDDSS
- clientData, trace, variable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v.1.0 Printed: July 31, 1990 4
-
-
-
-